
{extend name='table'}



{block name="content"}
<div class="layui-card padding-20 shadow layui-card-body" >
    {include file='pricing_rules/index_search'}
    <table id="PricingRulesTable" data-url="{:sysuri()}" data-target-search="form.form-search"></table>
</div>
{/block}
{block name='script'}
<script>
    $(function () {
        // 初始化表格组件
        $('#PricingRulesTable').layTable({
            even: true, height: 'full',
           // sort: {field: 'uuid desc', type: 'desc'},
            cols: cols = [[
                {checkbox: true, fixed: true},
                {field: 'stage', title: '处理阶段', align: "center", minWidth: 200,edit: 'text'},
                {field: 'stage_tag', title: '处理阶段标识', align: "center", minWidth: 200,edit: 'text'},
                {field: 'platform', title: '平台名称', align: "center", minWidth: 120,edit: 'text'},
                {field: 'cost_per_unit', title: '每单位成本', align: "center", minWidth: 120,edit: 'text'},
                {field: 'price_per_unit', title: '每单位售价', align: "center", minWidth: 200,edit: 'text'},
                {field: 'unit_number', title: '单位数值', align: "center", minWidth: 120,edit: 'text'},
                {field: 'unit_description', title: '单位描述', align: "center", minWidth: 120,edit: 'text'},
                {field: 'model', title: '大模型', align: "center", minWidth: 120,edit: 'text'},
                {field: 'create_at', title: '发布时间', align: 'center', minWidth: 120,},
                {toolbar: '#toolbar', title: '操作面板', align: 'center', minWidth: 150, fixed: 'right'},
            ]]

        });
        // 单元格编辑事件
        layui.table.on('edit(PricingRulesTable)', function(obj){
            var field = obj.field; // 得到修改的字段
            var value = obj.value // 得到修改后的值
            var data = obj.data // 得到所在行所有键
            console.log(obj); // 查看对象所有成员
            $.form.load("{:url('edit')}",data, 'post', function (ret) {
                if (ret.code < 1) $.msg.error(ret.info, 3, function () {
                    $('#PricingRulesTable').trigger('reload');
                }); else {
                    $('#PricingRulesTable').trigger('reload')
                }
                return false;
            })

        });



    });

</script>



<!-- 数据操作工具条模板 -->
<script type="text/html" id="toolbar">
    <!--{if auth("edit") }-->
    <a class="layui-btn layui-btn-primary layui-btn-sm"   data-modal='{:url("edit")}?id={{d.id}}'>编 辑</a>
    <!--{/if}-->

    <!--{if auth("remove") }-->
    <a class="layui-btn layui-btn-danger layui-btn-sm" data-action="{:url('remove')}" data-value="id#{{d.id}}" data-confirm="确定要删除吗?">删 除</a>
    <!--{/if}-->
</script>
{/block}
